<script> 
    $().ready(function(){          
        $('select[name=txt_group]').change(function(){
         var group = $(this).val();
         var id = $(this).attr('id');        
         $.ajax({
            type : "GET",
            dataType : "json",
            url  : "<?php echo base_url().'admin/setting/change_group'?>",
            data : 'id=' + id + '&group=' + group,
            success : function(result)
            {
               alert(result.error);
                return false;
            }
            
         });
        }); 
         $('select[name=txt_active]').change(function(){
           var active = $(this).val();
             var id = $(this).attr('id');        
             $.ajax({
                type : "GET",
                dataType : "json",
                url  : "<?php echo base_url().'admin/setting/change_active'?>",
                data : 'id=' + id + '&active=' + active,
                success : function(result)
                {
                   alert(result.error);
                   return false;
                }
                
             });
        });
    });
</script>

<div class="info">
<div class="place"></div>
<h1 class="font_h1">Người dùng và phân quyền</h1>
<?php if($this->session->flashdata('error') !='')  : ?>
<h2 class="error_red"><?php echo $this->session->flashdata('error');?></h2>
<?php endif;?>
<table cellpadding="0" cellspacing="0" style="background:#FFF; color:#000; ">
        <tr class="tr">        	
            <td>Tên đăng nhập</td>
            <td>Nhóm quyền</td>
            <td>Tên đầy đủ</td>  
            <td>Địa chỉ email</td>    
            <td>Kích hoạt</td>           
            <td colspan="2">Hành động</td>            
        </tr>
        <?php foreach($show_user as $row):?>
        <tr style="text-align:center">
        	<td><?php echo $row->username;?></td>
            <td>
            <select name="txt_group" id="<?php echo $row->id;?>"  style="width:80px">
            	<option value="1" <?php if($row->level == '1') echo "selected"?>>Tester</option>
                <option value="2" <?php if($row->level == '2') echo "selected"?>>Demo</option>
            </select>
            </td>
            <td><?php echo $row->fullname;?></td>
            <td><?php echo $row->email;?></td>
            <td>
            <select name="txt_active" id="<?php echo $row->id;?>" style="width:120px">
            	<option value="1" <?php if($row->active == '1') echo "selected"?>>Hiển thị</option>
                <option value="0" <?php if($row->active == '0') echo "selected"?>>Không hiện thị</option>
            </select>
            </td>
            <td>
            	<a href="<?php echo base_url().'admin/setting/user_add/'.$row->id;?>" title="Edit"><img src="<?php echo base_url()?>public/admin/images/user_edit.png"></a>&nbsp;&nbsp;&nbsp;<a href="<?php echo base_url().'admin/setting/delete_user/'.$row->id;?>" title="Delete"><img src="<?php echo base_url()?>public/admin/images/trash.png"></a>
            </td>
        </tr>
        <?php endforeach; ?>

</table>

</form>
<a href="<?php echo base_url()?>admin/setting/user_add" class="button">Tạo mới</a>
</div>
